unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Btnv_1: TButton;
    Btnv_2: TButton;
    Btnv_3: TButton;
    procedure Btnv_1Click(Sender: TObject);
    procedure Btnv_2Click(Sender: TObject);
    procedure Btnv_3Click(Sender: TObject);
  private
    l:TStringList;
  public
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzDebug,Class_KzUtils;

{$R *.dfm}

function kzCustomSort(List: TStringList; Index1, Index2: Integer): Integer;
var
  V1:string;
  V2:string;
begin
  V1:=List.Strings[Index1];
  V2:=List.Strings[Index2];

  Result:=CompareStr(V1,V2);

end;

procedure TForm1.Btnv_1Click(Sender: TObject);
var
  List:TStringList;
begin
  try
    List:=TStringList.Create;
    List.Add('A20160512');
    List.Add('B20160512');
    List.Add('A20160515');
    List.Add('B20160515');
    List.Add('A20160523');
    List.Add('B20160523');

    List.CustomSort(kzCustomSort);

    KzDebug.FileLog(List.Text);
  finally
    FreeAndNil(List);
  end;
end;

procedure TForm1.Btnv_2Click(Sender: TObject);
var
  I:Integer;
  v:TForm;
begin
  if l=nil then
  begin
    l:=TStringList.Create;
  end;
  TKzUtils.JustCleanList(l);
  for I:=0 to 10000 do
  begin
    v:=TForm.Create(nil);


    l.AddObject('',v);
  end;
end;

procedure TForm1.Btnv_3Click(Sender: TObject);
begin
   if l<>nil then TKzUtils.TryFreeAndNil(l);
end;

end.
